<?php
    if(isset($form['#farmer'])&& !empty($form['#farmer'])) {
        echo get_template_header_info($form['#farmer']);
    }
?>
<?php
if(isset($form['#addr_id'])&& !empty($form['#addr_id'])) {
    echo get_template_header_info($form['#addr_id'], 'village');
}
?>
<div class="hp-tab-newprd">
    <ul class="j-sw-nav">
        <?php if(!$form['#farmer'] && !$form['#addr_id']){?>
            <li class="newprd-s1 tab-li"><a href="<?php echo base_path();?>fertilizer_case/list">查看</a></li>
            <li class="newprd-s1 tab-li on"><a href="<?php echo base_path();?>fertilizer_case/overview">概览</a></li>
        <?php if(user_access('add fertilizer_case')){?>
            <li class="newprd-s2 tab-li"><a href="<?php echo base_path();?>fertilizer_case/add">添加</a></li>
        <?php }
        }else if(isset($form['#addr_id'])&& !empty($form['#addr_id'])){
            echo get_tab($form['#addr_id'],'fertilizer_case','village');
            ?>
        <?php }else if(isset($form['#farmer'])&& !empty($form['#farmer'])){?>
            <?php echo get_tab($form['#farmer'],'fertilizer'); ?>
        <?php }?>
    </ul>
    <div class="newprd-s1">
        <div class="table-div">
            <?php if(isset($form['#farmer'])&& !empty($form['#farmer'])){?>
                <ul class="table-ul-li">
                    <li><a href="<?php echo base_path(); ?>fertilizer_case/list?farmer_id=<?php echo $form['#farmer']?>" class="selected">列表</a></li>
                    <?php if(user_access('add fertilizer_case')){?>
                    <li>|</li>
                    <li><a href="<?php echo base_path(); ?>fertilizer_case/add?farmer_id=<?php echo $form['#farmer']?>">添加</a></li>
                    <?php } ?>
                </ul>
            <?php }?>
            <?php if(isset($form['#addr_id'])&& !empty($form['#addr_id'])){?>
                <ul class="table-ul-li">
                    <li><a href="<?php echo base_path(); ?>fertilizer_case/list?addr_id=<?php echo $form['#addr_id']?>" class="selected">列表</a></li>
                    <?php if(user_access('add fertilizer_case')){?>
                    <li>|</li>
                    <li><a href="<?php echo base_path(); ?>fertilizer_case/add?addr_id=<?php echo $form['#addr_id']?>">添加</a></li>
                    <?php } ?>
                </ul>
            <?php }?>
<!--            <div class="search-div">-->
<!--                --><?php //if(empty( $form['#farmer'])&&empty( $form['#addr_id'])){?>
<!--                <div class="small-select"><div class="search-label">请选地址:</div>--><?php //print render($form['address']); ?><!--</div>-->
<!--                --><?php //}?>
<!--                <div class="small-select small-input" style="clear:both"><div class="search-label">农作物:</div>--><?php //print render($form['plant']); ?><!--</div>-->
<!--                <div class="search-submit">--><?php //print render($form['submit']); ?><!--</div>-->
<!--            </div>-->
<!--            <img class="res-search" style="clear:both" src='--><?php //echo base_path();?><!--sites/all/themes/tweme/images/images/res.png'>-->
<!--            <div class="table-div">-->
<!--                --><?php //print render($form['table']); ?>
<!--            </div>-->

            <?php if(user_access('view own fertilizer_case')){ ?>
                <div class="fieldset-div revisit-info-div <?php echo count($form['#fertilizer']);?>">
                    <div class="fieldset-title">施肥案例<div style="float: right"><span class="datacount 4">4条</span><span class="datacount 8">8条</span><span class="datacount 12">12条</span><span class="datacount 16">16条</span><span class="datacount 20">20条</span></div></div>
                    <?php foreach($form['#fertilizer'] as $key => $val){ ?>
                        <div class="fieldset-content fertilizer-field" style="  margin-bottom: 6px;">
                            <table class="fieldset-table">
                                <tbody>
                                <tr>
                                    <td class="fieldset-tr-title">农户姓名:<?php echo $val->farmer_name;?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">作物:<?php echo $val->plant_name;?></td>
                                </tr>
                                </tbody>
                            </table>

                            <table class="fieldset-table">
                                <tbody>
                                <tr>
                                    <td class="fieldset-tr-title">效果描述:<?php echo mb_substr($val->effect_desc,0,5);?></td>
                                </tr>
                                <tr>
                                    <td class="fieldset-tr-title">实际产量:<?php echo $val->real_yield;?></td>
                                </tr>
                                </tbody>
                            </table>

<!--                            <table class="fieldset-table">-->
<!--                                <tbody>-->
<!--                                <tr>-->
<!--                                    <td class="fieldset-tr-title">-->
                            <div style="clear:both;" class="fieldset-tr-title">地址:
                                        <?php
                                            if($val->province){
                                                echo $val->province;
                                            }
                                            if($val->city){
                                                echo ' '.$val->city;
                                            }
                                            if($val->county){
                                                echo ' '.$val->county;
                                            }
                                            if($val->town){
                                                echo ' '.$val->town;
                                            }
                                        if($val->village){
                                            echo ' '.$val->village;
                                        }
                                        ?></div>
<!--                                    </td>-->
<!--                                </tr>-->
<!--                                </tbody>-->
<!--                            </table>-->
                        </div>
                    <?php }?>
                    <div style="clear: both;"></div>
                </div>
            <?php }?>
        </div>
    </div>
</div>

<?php print drupal_render_children($form); ?>
